package StudyCode.summary.mycollection;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class RotateArray {
	public static void rotateArray(Integer[] arr, int index, int rotateBy) {

		for (int x = 0; x < arr.length; x++) {
			int newLocation = ((x + rotateBy) - 1) % arr.length;
			swapValues(arr, x, newLocation);
		}
	}

	public static <T> void swapValues(T array[], int index, int otherIndex) {
		T tempVal = array[otherIndex];
		array[otherIndex] = array[index];
		array[index] = tempVal;
	}
}
